package net.mymilkedeek.ludum.tinythumb.states;

import net.mymilkedeek.ludum.tinythumb.Game;
import net.mymilkedeek.ludum.tinythumb.model.Battaljar;
import net.mymilkedeek.ludum.tinythumb.util.Constants;
import net.mymilkedeek.ludum.tinythumb.util.URL;
import org.newdawn.slick.*;
import org.newdawn.slick.state.BasicGameState;
import org.newdawn.slick.state.StateBasedGame;

/**
 * TODO: Write Documentation
 *
 * @author Michael Demey
 */
public class PartyState extends BasicGameState {
    @Override
    public int getID() {
        return Game.S_PARTY;
    }

    private Animation thumb;
    private Image chicken;

    @Override
    public void init(GameContainer gameContainer, StateBasedGame stateBasedGame) throws SlickException {
        thumb = new Animation(new SpriteSheet(URL.character_sprites_down, Constants.tile_size, Constants.tile_size), Constants.animation_character_refresh_speed);
        chicken = new Image(URL.chicken_sprite);
    }

    @Override
    public void render(GameContainer gameContainer, StateBasedGame stateBasedGame, Graphics graphics) throws SlickException {
        graphics.setColor(Color.white);

        int y = 100;
        int x = 50;

        thumb.draw(x, y - 50);

        graphics.drawString(Battaljar.party1.getMember1().name + " Lv. " + Battaljar.party1.getMember1().lvl, x, y);
        graphics.drawString("hp : " + Battaljar.party1.getMember1().hp, x, y + 20);
        graphics.drawString("atk: " + Battaljar.party1.getMember1().atk, x, y + 40);
        graphics.drawString("def: " + Battaljar.party1.getMember1().def, x, y + 60);
        graphics.drawString("Next Lv: " + Battaljar.party1.getMember1().xptoNxt, x, y + 80);

        x += 150;

        chicken.draw(x, y - 50);

        graphics.drawString(Battaljar.party1.getMember2().name + " Lv. " + Battaljar.party1.getMember2().lvl, x, y);
        graphics.drawString("hp : " + Battaljar.party1.getMember2().hp, x, y + 20);
        graphics.drawString("atk: " + Battaljar.party1.getMember2().atk, x, y + 40);
        graphics.drawString("def: " + Battaljar.party1.getMember2().def, x, y + 60);
        graphics.drawString("Next Lv: " + Battaljar.party1.getMember2().xptoNxt, x, y + 80);
        
        graphics.drawString("< p to exit >", 150, y + 150);
    }

    @Override
    public void update(GameContainer gameContainer, StateBasedGame stateBasedGame, int i) throws SlickException {
        if ( gameContainer.getInput().isKeyPressed(Input.KEY_P)) {
            stateBasedGame.enterState(Game.S_MAIN);
        }
    }
}
